package comm

// 实现大端字节序编解码

import "encoding/binary"

var (
	BE = bigEndian{
		binary.BigEndian,
	}
)

type bigEndian struct {
	binary.ByteOrder
}

func (bigEndian) Uint24(b []byte) uint32 {
	return uint32(b[2]) | uint32(b[1])<<8 | uint32(b[0])<<16
}

func (bigEndian) PutUint24(b []byte, v uint32) {
	b[0] = byte(v >> 16)
	b[1] = byte(v >> 8)
	b[2] = byte(v)
}
